/*
 * INSANE - Interactive Structural Analysis Environment
 *
 * Copyright (C) 2003-2006
 * Universidade Federal de Minas Gerais
 * Escola de Engenharia
 * Departamento de Engenharia de Estruturas
 *
 * Author's email :     insane@dees.ufmg.br
 * Author's Website :   http://www.dees.ufmg.br/insane
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 */
 
package br.ufmg.dees.insane.ui.rich.full.command;

import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Locale;
import java.util.Properties;

import javax.swing.JFrame;
import javax.swing.UIManager;

import br.ufmg.dees.insane.commons.command.Command;
import br.ufmg.dees.insane.ui.rich.full.InsaneInterface;

/**
 *
 * @author Fonseca, Flavio & Pitangueira, Roque
 * @since March 2006
 */
public class SetToEnglishCommand implements Command {
	
    private InsaneInterface parent;
    
//*****************************************************************************
	
    /** Creates new settingCommand */
    public SetToEnglishCommand(JFrame parent) {
        this.parent = (InsaneInterface)parent;
    }
    
//*****************************************************************************
	
    public void execute() {
        parent.setLocale(new Locale("", "", ""));
		parent.setAllLabels();
		this.updateUI();
		this.savePropertiesFile();
		parent.addOutputText("Language changed to English.");
    }
	
//*****************************************************************************
	
    public void undo() {
    }
    
//*****************************************************************************
	
    public void redo() {
    }
    
//*****************************************************************************
	
	public void updateUI(){
		
		UIManager.put("ColorChooser.sampleText","Sample Text");
		UIManager.put("ColorChooser.swatchesNameText","Choose");
		UIManager.put("ColorChooser.resetText", "Reset");
		UIManager.put("ColorChooser.previewText", "Preview");
		UIManager.put("ColorChooser.cancelText", "Cancel");
		UIManager.put("ColorChooser.swatchesRecentText", "Recents:");
		UIManager.put("ColorChooser.rgbBlueText", "Blue");
		UIManager.put("ColorChooser.rgbGreenText", "Green");
		UIManager.put("ColorChooser.rgbRedText", "Red");
		//OptionPane
		UIManager.put("OptionPane.cancelButtonText", "Cancel");
		UIManager.put("OptionPane.noButtonText", "No");
		UIManager.put("OptionPane.okButtonText", "OK");
		UIManager.put("OptionPane.yesButtonText", "Yes");
		//FileChooser
		UIManager.put("FileChooser.acceptAllFileFilterText", "All Files (*.*)");
		UIManager.put("FileChooser.cancelButtonText", "Cancel");
		UIManager.put("FileChooser.cancelButtonToolTipText", "Abort file chooser dialog");
		UIManager.put("FileChooser.detailsViewButtonAccessibleName", "Details");
		UIManager.put("FileChooser.detailsViewButtonToolTipText", "Details");
		UIManager.put("FileChooser.directoryDescriptionText", "Directory");
		UIManager.put("FileChooser.fileDescriptionText", "Generic File");
		UIManager.put("FileChooser.fileNameLabelText", "File name:");
		UIManager.put("FileChooser.filesOfTypeLabelText", "Files of type:");
		UIManager.put("FileChooser.helpButtonText", "Help");
		UIManager.put("FileChooser.helpButtonToolTipText", "FileChooser help");
		UIManager.put("FileChooser.homeFolderAccessibleName", "Home");
		UIManager.put("FileChooser.homeFolderToolTipText", "Home");
		UIManager.put("FileChooser.listViewButtonAccessibleName", "List");
		UIManager.put("FileChooser.listViewButtonToolTipText", "List");
		UIManager.put("FileChooser.lookInLabelText", "Look in:");
		UIManager.put("FileChooser.saveInLabelText", "Save in:");
		UIManager.put("FileChooser.newFolderAccessibleNam", "New Folder");
		UIManager.put("FileChooser.newFolderErrorText", "Error creating new folder");
		UIManager.put("FileChooser.newFolderToolTipText", "Create New Folder");
		UIManager.put("FileChooser.openButtonText", "Open");
		UIManager.put("FileChooser.openButtonToolTipText", "Open selected file");
		UIManager.put("FileChooser.saveButtonText", "Save");
		UIManager.put("FileChooser.saveButtonToolTipText", "Save selected file");
		UIManager.put("FileChooser.updateButtonText", "Update");
		UIManager.put("FileChooser.updateButtonToolTipText", "Update directory listing");
		UIManager.put("FileChooser.upFolderAccessibleName", "Up");
		UIManager.put("FileChooser.upFolderToolTipText", "Up One Level");
		
	}
	
//*****************************************************************************
	
	public void savePropertiesFile() {
		try { 
         Properties properties = new Properties();
		 properties.setProperty("language", "english");
		 properties.store(new FileOutputStream("lib/Insane.properties"), "#Insane properties file");
		} catch (IOException e) {
			parent.addOutputText("Erro gravando arquivo");
		}
	}
	
//*****************************************************************************
}
